package com.funwell.server.constants;


/**
 * 邮件常量
 */
public class EmailConstants {

  /**
   * 邮件发送类型
   * 
   * @code 类型
   * @templet 邮件模板
   */
  public static enum EmailSendInfo {
    /**
     * 注册
     * 
     * @code 1
     */
    REGIST((byte) 1, "注册", ""),
    /**
     * 修改密码
     * 
     * @code 2
     */
    CHANGE_PWD((byte) 2, "修改密码", ""),
    /**
     * 找回密码
     * 
     * @code 3
     */
    FIND_PWD((byte) 3, "找回密码", "尊敬的亲亲跟P虫用户，你好！恭喜您的密码找回成功。您的新密码是%s。返回APP重新登录即可生效。");

    public byte code;
    public String subject;
    public String templet;

    private EmailSendInfo(byte code, String subject, String templet) {
      this.code = code;
      this.subject = subject;
      this.templet = templet;
    }

    /**
     * 根据code获取模板
     * 
     * @param code
     * @return
     */
    public static String getTemplet(byte code) {
      EmailSendInfo[] elements = EmailSendInfo.values();

      for (int i = 0; i < elements.length; i++) {
        if (elements[i].code == code) {
          return elements[i].templet;
        }
      }
      return null;
    }

    /**
     * 根据code获取模板SmsType
     * 
     * @param code
     * @return
     */
    public static EmailSendInfo getEmailType(byte code) {
      EmailSendInfo[] elements = EmailSendInfo.values();
      for (int i = 0; i < elements.length; i++) {
        if (elements[i].code == code) {
          return elements[i];
        }
      }
      return null;
    }
  }

  /**
   * 邮件发送缓存 EMAIL_type_email
   */
  public static final String EMAIL_KEY = "EMAIL_%s_%s";

  /**
   * 邮件发送冷却时间(秒) 1分钟
   */
  public static final int EMAIL_COOL_TIME = 60;
  
}
